]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appFavorites: Display its own notification for every pin/unpin
authorJulian Sparber <julian@sparber.net>
Thu, 7 Mar 2024 15:24:44 +0000 (16:24 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 29 Jul 2024 14:57:42 +0000 (14:57 +0000)
Show a notification for each user action instead of updating the
notification currently displayed when the user pins or unpins.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3387>

js/ui/appFavorites.js

index 576df3800d5da10c9bb2983eab0b4f1bdbc679e8..02ec93f15b8fb40050211eea7af644d6522fc9b1 100644 (file)
@@ -1,11 +1,10 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
+import * as MessageTray from './messageTray.js';
 import Shell from 'gi://Shell';
 import * as ParentalControlsManager from '../misc/parentalControlsManager.js';
 import * as Signals from '../misc/signals.js';
 
-import * as Main from './main.js';
-
 // In alphabetical order
 const RENAMED_DESKTOP_IDS = {
     'baobab.desktop': 'org.gnome.baobab.desktop',
@@ -161,13 +160,11 @@ class AppFavorites extends Signals.EventEmitter {
         if (!this._addFavorite(appId, pos))
             return;
 
-        let app = Shell.AppSystem.get_default().lookup_app(appId);
+        const app = Shell.AppSystem.get_default().lookup_app(appId);
 
-        let msg = _('%s has been pinned to the dash.').format(app.get_name());
-        Main.overview.setMessage(msg, {
-            forFeedback: true,
-            undoCallback: () => this._removeFavorite(appId),
-        });
+        this._showNotification(_('%s has been pinned to the dash.').format(app.get_name()),
+            null,
+            () => this._removeFavorite(appId));
     }
 
     addFavorite(appId) {
@@ -196,11 +193,22 @@ class AppFavorites extends Signals.EventEmitter {
         if (!this._removeFavorite(appId))
             return;
 
-        let msg = _('%s has been unpinned from the dash.').format(app.get_name());
-        Main.overview.setMessage(msg, {
+        this._showNotification(_('%s has been unpinned from the dash.').format(app.get_name()),
+            null,
+            () => this._addFavorite(appId, pos));
+    }
+
+    _showNotification(title, body, undoCallback) {
+        const source = MessageTray.getSystemSource();
+        const notification = new MessageTray.Notification({
+            source,
+            title,
+            body,
+            isTransient: true,
             forFeedback: true,
-            undoCallback: () => this._addFavorite(appId, pos),
         });
+        notification.addAction(_('Undo'), () => undoCallback());
+        source.addNotification(notification);
     }
 }